﻿namespace Hidistro.UI.SaleSystem.Tags
{
    using Hidistro.Entities.Commodities;
    using Hidistro.SaleSystem.Catalog;
    using Hidistro.UI.Common.Controls;
    using JSShop.Model;
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using System.Web.UI.WebControls;
   

    public class Common_ProductCategoryList : ThemedTemplatedRepeater
    {
        private int categoryId;
        private int maxNum = 0x3e8;

        private void BindList()
        {
            if (this.categoryId != 0)
            {

                List<JSShop.Model.Hishop_Categories> maxSubCategories = new Juse.Interface.CategoryBrowser().GetSubCategoriesR(this.categoryId, 0);
                if (maxSubCategories.Count <= 0)
                {
                    IList<CategoryInfo> maxSubCategoriesss = CategoryBrowser.GetMaxSubCategories(this.categoryId, this.MaxNum);
                    base.DataSource = maxSubCategoriesss;
                    base.DataBind();
                }
                base.DataSource = maxSubCategories;
                base.DataBind();
            }
            else
            {
                List<JSShop.Model.Hishop_Categories> maxSubCategories = new Juse.Interface.CategoryBrowser().GetSubCategories(0, 0);
                base.DataSource = maxSubCategories;
                base.DataBind();
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            if (this.IsShowSubCategory)
            {
                int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            }
            this.BindList();
        }

        public bool IsShowSubCategory { get; set; }

        public int MaxNum
        {
            get
            {
                return this.maxNum;
            }
            set
            {
                this.maxNum = value;
            }
        }

       
    }
}

